#pragma once

class CMainFrame;

class CCharacter :
	public CD3DWOWM2CharacterModel
{
protected:
	enum ACTION_STATUS
	{
		ACTION_STATUS_NONE,
		ACTION_STATUS_JUMP_START,
		ACTION_STATUS_JUMP_FLY,
		ACTION_STATUS_JUMP_END,
	};
	CGameState *		m_pState;
	CMoveStatus			m_MoveStatus;
	CBaseCharInfo		m_CharInfo;

	BYTE				m_QueryMoveStatus;	
	

	int					m_ActionStatus;
	CEasyTimer			m_ActionTimer;

	float				m_JumpStartSpeed;
	float				m_JumpStartHeight;
	float				m_JumpStartTime;

	//CD3DLine			m_TestLine1;
	//CD3DLine			m_TestLine2;

	DECLARE_CLASS_INFO(CCharacter)
public:
	CCharacter(void);
	virtual ~CCharacter(void);

	bool Init(CGameState * pState);

	
	virtual void Update(FLOAT Time);

	void SetStatus(CSmartStruct& MoveStatus);
	bool UpdateStatus(FLOAT Time);

	bool SetCharData(CSmartStruct& CharData);

	void QueryMove(BYTE MoveStatus,int RotationStatus);
	void QueryJump();

	
	UINT64 GetPlayerID()
	{
		return m_CharInfo.GetCharID();
	}
	BYTE GetRotateStatus()
	{
		return m_MoveStatus.GetRotateStatus();
	}

	CMoveStatus& GetMoveStatus()
	{
		return m_MoveStatus;
	}
	CBaseCharInfo& GetCharInfo()
	{
		return m_CharInfo;
	}
	
	void DoJumpStart();
protected:
	void ApplyMoveAction();
	void ApplyRotateAction();
	void DoFallStart();
	void DoJumpEnd();

	void SyncPos();
	void CaculateMoveTarget(BYTE MoveStatus,float MoveSpeed,float StartPosX,float StartPosY,float Direction,float& TargetPosX,float& TargetPosY);
	BYTE CheckMove(BYTE MoveStatus,float& TargetPosX,float& TargetPosY,float& TargetHeight);
};
